<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
<!--
div {
	font-size: 12px
}

ul {
	list-style: none;
}

.clear {
	clear: both
}
.close{
	cursor:pointer;
}
.close:hover{
	color:red;
	border:#666 solid 1px;
	padding:2px;
}
.open{
	cursor:pointer;
}
.open:hover{
	color:red;
	border:#666 solid 1px;
	padding:2px;
}
.add{
	margin-left:5px;
	cursor:pointer;
}
.add:hover{
	color:red;
	border:#666 solid 1px;
	padding:2px;
}
</style>
<script src="<?=base_url('js/tbk.js') ?>"></script>
<script>
$(document).ready(function (){
	for(var i=0;i<<?=count($nav) ?>;i++){
		$("#s_"+i+" .close").text("打开");
	}
})
$(".close").live("click",function (){
	$(this).parent().find("ul").show();
	$(this).parent().find(".add").show();
	$(this).text("关闭");
	$(this).attr("class","open");
})
$(".open").live("click",function (){
	$(this).parent().find("ul").hide();
	$(this).parent().find(".add").hide();
	$(this).attr("class","close");
	$(this).text("打开");
})
$(".add").live("click",function (){
	$ul = $(this).parent().find("ul");
	var key = $(this).parent().attr("id").substr(2);
	var k = $ul.find("li").length;
	var html = "<li>新添加小类：<input type=text name=c_"+key+"_"+k+" value='' /></li>";
	$ul.append(html);
})
</script>
</head>

<body>
	<h1></h1>
	<div>
		<form action="<?=site_url('admin/index/topnavpost') ?>" method="post"
			target="mainFrame">
			<ul>
				<?php foreach ($nav as $key=>$v):?>
				<li id="s_<?=$key ?>" >
					大类：
					<input type="text" name="f_<?=$key ?>" value="<?=$v->name?>" />
					<input type="hidden" name="id_<?=$key ?>" value="<?=$v->id?>" />
					<a class="close"></a><a class="add" style="display:none">添加分类</a>
					<ul style="display:none">
					<?php foreach ($v->c_nav as $k=>$vv):?>
						<li>小类：
							<input type="text" name="c_<?=$key ?>_<?=$k ?>" value="<?=$vv->name ?>" />
							<input type="hidden" name="id_<?=$key ?>_<?=$k ?>" value="<?=$vv->id?>" />
							</li>
					<?php endforeach;?>
					</ul>
				</li>
				<?php endforeach;?>
			</ul>
			<div class="clear"></div>
			<div class="clear"></div>
			<ul>
				<li></li>
				<li><input type="submit" value="确认修改" /></li>
			</ul>
		</form>
	</div>
</body>
</html>
